{% extends "base.html" %}

{% block title %}编辑收费记录{% endblock %}

{% block content %}
<div class="row">
    <div class="col-md-8 offset-md-2">
        <h2 class="mb-4">编辑收费记录</h2>
        <div class="alert alert-info">
            <strong>学生信息：</strong>{{ payment.student }} - {{ payment.class_name }}
        </div>
        <form method="POST">
            <div class="mb-3">
                <label for="payment_date" class="form-label">收费日期</label>
                <input type="date" class="form-control" id="payment_date" name="payment_date" value="{{ payment.date.strftime('%Y-%m-%d') }}" required>
            </div>
            <div class="mb-3">
                <label for="project" class="form-label">收费项目</label>
                <div class="input-group">
                    <select class="form-control" id="project" name="project" required>
                        <option value="">请选择收费项目</option>
                        {% for project in projects %}
                        <option value="{{ project.name }}" {% if payment.project == project.name %}selected{% endif %}>{{ project.name }}</option>
                        {% endfor %}
                    </select>
                    <a href="{{ url_for('add_project') }}" class="btn btn-primary" target="_blank">添加收费项目</a>
                </div>
            </div>
            <div class="mb-3">
                <label for="amount" class="form-label">金额</label>
                <input type="number" step="0.01" class="form-control" id="amount" name="amount" value="{{ payment.amount }}" required>
            </div>
            <div class="mb-3">
                <label for="account" class="form-label">收款账号</label>
                <div class="input-group">
                    <select class="form-control" id="account" name="account" required>
                        <option value="">请选择收款账号</option>
                        {% for account in accounts %}
                        <option value="{{ account.account }}" {% if payment.account == account.account %}selected{% endif %}>{{ account.account }}</option>
                        {% endfor %}
                    </select>
                    <a href="{{ url_for('add_account') }}" class="btn btn-primary" target="_blank">添加收款账号</a>
                </div>
            </div>
            <div class="mb-3">
                <label for="summary" class="form-label">摘要</label>
                <textarea class="form-control" id="summary" name="summary" rows="3">{{ payment.summary }}</textarea>
            </div>
            <div class="mb-3">
                <button type="submit" class="btn btn-primary">保存</button>
                <a href="{{ url_for('list_payments') }}" class="btn btn-secondary">返回</a>
            </div>
        </form>
    </div>
</div>
{% endblock %} 